package com.yesun.dcm.rpc.proxy;

import com.yesun.dcm.commons.rpc.URL;
import com.yesun.dcm.rpc.Invoker;
import com.yesun.dcm.rpc.RpcRequest;
import com.yesun.dcm.rpc.RpcResponse;

/**
 * 抽象代理Invoker，为AbstractProxyFactory使用
 * @param <T>
 */
public abstract class AbstractProxyInvoker<T> implements Invoker<T> {

    private T proxy;
    private Class<T> clazz;
    private URL url;

    public AbstractProxyInvoker(T poxy, Class<T> clazz, URL url) {
        this.proxy = proxy;
        this.clazz = clazz;
        this.url = url;
    }

    @Override
    public URL getURL() {
        return url;
    }

    @Override
    public Class<T> getInterface() {
        return clazz;
    }

    @Override
    public RpcResponse invoke(RpcRequest request) {
        return null; //TODO
    }

    //never used //TODO
    protected abstract Object doInvoke(T proxy, String methodName, Class<?>[] parameterTypes, Object[] arguments) throws Throwable;
}
